home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / DMultiStringLocator / source / CSearchWindow.h < prev    next >
Text File  |  1996-07-06  |  3KB  |  132 lines

  1. // ===========================================================================
  2. // CSearchWindow.h
  3. //   ---------------------
  4. //   ©1996 Eric Gundrum, All rights reserved.
  5. //   The contents of this file may be freely altered and freely distributed
  6. //   in any form, provided this copyright statement is retained unaltered.
  7. //   Add your own changes below.
  8. //   ---------------------
  9. //    
  10. //    Coordinate activities of the Search Window.  
  11. //
  12.  
  13. #pragma once
  14.  
  15. // PowerPlant Headers
  16. #include <LListener.h>
  17. #include <LWindow.h>
  18.  
  19. // Library Headers
  20. #include "DMultiStringLocator.h"
  21.  
  22.  
  23. #pragma mark --- CSearchString declarations ---
  24. // ===========================================================================
  25. //    Container for a search string and its report function.
  26.  
  27. class CSearchString    :    public DSearchString
  28. {
  29. public:
  30.                             CSearchString();
  31.     virtual    Boolean            ReportFound( long /*inPosition*/ );
  32.     static    Int32            SetBufferOffset( Int32 inOffset );
  33.             Int32            GetFoundCount()    { return mFoundCount; }
  34.             
  35. private:
  36.                 Int32    mFoundCount;
  37.                 long    mLastFoundPosition;    // location of end of last found
  38.     static        long    mBufferOffset;        // file position of start of buffer
  39. };
  40.  
  41.  
  42. // ---------------------------------------------------------------------------
  43. //
  44. inline
  45. CSearchString::CSearchString()
  46.     mFoundCount         = 0;
  47.     mLastFoundPosition    = 0;
  48. }
  49.  
  50.  
  51. // ---------------------------------------------------------------------------
  52. //
  53. inline Boolean
  54. CSearchString::ReportFound( long inPosition )
  55.     inPosition    += mBufferOffset;    // normalize found position
  56.     if ( inPosition > mLastFoundPosition )    // new found string
  57.     {
  58.         mLastFoundPosition = inPosition;
  59.         mFoundCount += 1;
  60.     }
  61.     return true;
  62. }
  63.  
  64.  
  65. // ---------------------------------------------------------------------------
  66. //
  67. inline Int32
  68. CSearchString::SetBufferOffset( Int32 inOffset ) 
  69. {
  70.     return mBufferOffset = inOffset;
  71. }
  72.  
  73.  
  74. #pragma mark --- CSearchWindow declarations ---
  75. // ===========================================================================
  76. //    Search Window coordinator.
  77.  
  78. class CSearchWindow    :    public LListener
  79.                     ,    public LCommander
  80. {
  81. public:
  82.     virtual                    ~CSearchWindow();
  83.                             CSearchWindow();
  84.     
  85.             void            ShowSearchWindow();
  86.             void            DoSearch();
  87.             void            SearchFile( LFileStream &inTarget );
  88.             
  89.             Boolean            WindowExists()    { return    nil != mSearchWindowP; }
  90.     virtual    void            ListenToMessage(
  91.                                 MessageT    inMessage,
  92.                                 void*        ioParam
  93.                             );
  94.     virtual    Boolean            AllowSubRemoval( LCommander *inSubP );
  95.     
  96. private:
  97.                             // stop defaults
  98.                             CSearchWindow( const CSearchWindow &inOriginal );
  99.                             
  100.             void            InsertSearchItem
  101.                             ( Int32 inPos, LEditField &inEditField );
  102.             void            EmptySearchList();
  103.                             
  104.             LWindow            *mSearchWindowP;    // search queary window
  105.             LList            mSearchList;        // pointers to search strings
  106. public:
  107.     // Window identifiers
  108.     enum                {
  109.                             msg_FilterExecute        = 'FndB'
  110.                         ,    msg_FilterCancel        = 'CanB'
  111.                         };
  112.  
  113.     enum    PaneIDT        {
  114.                             button_FilterExecute    = 'FndB'
  115.                         ,    button_FilterCancel        = 'CanB'
  116.                         ,    editField_Target1        = 'St1E'
  117.                         ,    editField_Target2        = 'St2E'
  118.                         ,    editField_Target3        = 'St3E'
  119.                         ,    caption_Result1            = 'Sr1C'
  120.                         ,    caption_Result2            = 'Sr2C'
  121.                         ,    caption_Result3            = 'Sr3C'
  122.                         ,    caption_Duration        = 'SrDC'
  123.                         };
  124. };
  125.  
  126.     // Find Window resource identifiers
  127.     const    ResIDT        window_Search            = 1100;
  128.  
  129. // ===========================================================================
  130. //    EOF